# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from fastapi import Query
from pydantic import BaseModel, Field


class PayListenIn(BaseModel):
    """ 支付监听参数 """
    order_id: int = Query(..., gt=0, description="订单ID")
    attach: str = Query(..., pattern=r"^(recharge|subscribe)$", description="支付场景")

    class Config:
        json_schema_extra = {
            "example": {
                "order_id": 1,
                "attach": "recharge"
            }
        }

    @classmethod
    def messages(cls):
        return {
            "order_id.gt": "请指定订单",
            "attach.min_length": "请指定订单来源"
        }


class PayPrepayIn(BaseModel):
    """ 预支付参数 """
    order_id: int = Field(..., gt=0, description="订单ID")
    pay_way: int = Field(..., ge=2, le=3, description="支付方式: [1=余额,2=微信,3=支付宝]")
    attach: str = Field(..., pattern=r"^(recharge|subscribe)$", description="支付场景")
    redirect_url: str = Field(default="", max_length=1000, description="重定向Url")

    class Config:
        json_schema_extra = {
            "example": {
                "order_id": 1,
                "pay_way": 2,
                "attach": "recharge",
                "redirect_url": ""
            }
        }

    @classmethod
    def messages(cls):
        return {
            "order_id.gt": "请正确下单",
            "attach.min_length": "请指定订单来源"
        }


"""--------------- Separator ---------------"""


class PayWayListVo(BaseModel):
    """ 支付方式列表Vo """
    channel: int = Field(description="支付渠道")
    shorter: str = Field(description="支付名称")
    icon: str = Field(description="支付图标")

    class Config:
        json_schema_extra = {
            "example": {
                "channel": 2,
                "shorter": "微信支付",
                "icon": "https://www.xx.cn/wxpay.cn"
            }
        }


class PayListenVo(BaseModel):
    """ 支付监听结果Vo """
    status: int = Field(description="订单状态: [-1=订单不存在, 0=未支付, 1=已支付, 2=已过期]")
    message: str = Field(description="状态描述")

    class Config:
        json_schema_extra = {
            "example": {
                "status": 0,
                "message": "订单未支付"
            }
        }
